package com.yanyeori.webtest.config.filter;

import com.yanyeori.framework.core.model.WebResponse;
import com.yanyeori.framework.security.bo.UserDetail;
import com.yanyeori.framework.security.filter.FilterHandler;
import com.yanyeori.framework.security.filter.RequestFilter;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class RequestFilterConfig extends FilterHandler {

    @Override
    protected void configure(FilterManager filterManager) {
        filterManager
                .addFilter(new RequestFilter() {
                    @Override
                    public WebResponse handle(HttpServletRequest request, HttpServletResponse response, UserDetail userDetail) {
                        //验证逻辑
                        log.info("RequestFilter自定义请求验证被调用");
                        return WebResponse.ok();
                    }

                    @Override
                    public int getOrder() {
                        return Integer.MAX_VALUE;
                    }
                });
    }
}
